#ifdef _DEBUG
//#include <vld.h>
#endif

#include <iostream>
#include "EpilInterpreter.h"
#include "TCharSupport.h"

using namespace std;


EpilObjectVector EpilConsolePrint( EpilInterpreter * interpreter, const EpilObjectVector & params )
{
	for( EpilObjectVector::const_iterator it = params.begin(); it != params.end(); ++it )
	{
		tcout << (*it)->ToString() << t("\t");
	}
	tcout << endl;
	return EpilObjectVector();
}


int main()
{
	tcout << t("Epil 0.1  Developed by Fitbos under LGPL.") << endl;
	tcout << t("Type \"quit\" to quit.") << endl;
	tcout << endl;
	
	EpilInterpreter interpreter;
	interpreter.RegisterFunction( t("print"), EpilConsolePrint );

	for(;;)
	{
		tcout << t("> ");
		tstring curCommand = t("");
		getline( tcin, curCommand );

		if( curCommand == t("quit") )
		{
			break;
		}

		try
		{
			interpreter.RunString( curCommand );
		}
		catch( const EpilException & e )
		{
			tcout << e.GetCompleteMessage() << endl;
		}
	}

	return 0;
}